{extend name="public:base"}
{block name='css'}
{/block}

{block name='body'}
<div class="view view-main white-navbar white-page white-toolbar">
    <div data-name="home" class="page">

        <div class="navbar">
            <div class="navbar-inner">
                <div class="left"><a href="{$my_prev_url|default='/'}" class="external"><i class="iconfont icon-fanhui"></i></a></div>
                <div class="center"><span>商品评价</span></div>
                <div class="right"></div>
            </div>
        </div>

        <div class="page-content infinite-scroll-content">

            <div class="score-list">


            </div>
            {include file='public:loading' /}

        </div>

    </div>
</div>
{/block}

{block name="js"}
<script type="text/javascript">
    $(function(){
        getList();

    });

    function getList() {
        var total = $('.score-list .li').length;
        if (total % 10 != 0) {
            return false;
        }

        if ($('.loading').is(':visible') || $('.no-more').is(':visible') || $('.no-data').is(':visible')) {
            return false;
        }
        $('.loading').show();

        var p = total / 10;
        $.post("{:url('index/getGoodsEvaluateList')}", {page:p+1,goods_id:"{:input('goods_id')}"}, function(data){
            var str = '';
            $('.loading').hide();
            if (data.data.data.length > 0) {
                $.each(data.data.data, function(i,n){
                    str += '<div class="li">\n' +
                        '    <div class="user">\n' +
                        '        <img src="'+n.img+'" alt="" />\n' +
                        '        <span class="sp1">'+n.name+'</span>\n' +
                        '        <span class="sp2">'+n.add_time+'</span>\n' +
                        '    </div>\n' +
                        '    <div class="con">'+n.content+'</div>\n';
                    if (n.reply) {
                        str += '    <div class="huifu">\n' +
                            '        <span>回复：</span>' + n.reply + '\n' +
                            '    </div>\n'
                    }
                    str += '</div>';
                });
                if (data.data.data.length < 10) {
                    $('.no-more').show();
                }
                $(str).appendTo($('.score-list'));
            } else {
                if (total > 0) {
                    $('.no-more').show();
                } else {
                    $('.no-data').show();
                }
            }
        }, 'json');
    }

    //触发无限滚动
    $$('.infinite-scroll-content').on('infinite', function () {
        getList();
    });
</script>
{/block}